using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShootFactory : MonoBehaviour
{
    public ShootController shootController;
    public GameObject arrow;
    // Start is called before the first frame update
    void Start()
    {
        shootController = (ShootController)SSDirector.getInstance().currentSceneController;
    }

    public GameObject GetArrow() { // 获取空闲的箭
        arrow = GameObject.Instantiate(Resources.Load("Prefabs/Arrow", typeof(GameObject))) as GameObject;
        Transform bow_mid = shootController.Crossbow.transform.GetChild(4);
        arrow.transform.position = bow_mid.transform.position;
        arrow.transform.rotation = shootController.Crossbow.transform.rotation;
        arrow.transform.parent = shootController.Crossbow.transform;
        arrow.gameObject.SetActive(false); // 防止碰撞
        return arrow;
    }

    public void RecycleArrow(GameObject arrow) { //回收
        arrow.SetActive(false);
        DestroyImmediate(arrow);
    }
}
